package uploads_api

import (
	"gin_study_blog/common"
	"gin_study_blog/common/http"
	"gin_study_blog/models"
	"github.com/gin-gonic/gin"
)

type ImagesNameList struct {
	ID   uint   `json:"id"`
	Path string `json:"path"` // 图片路径
	Name string `json:"name"` // 图片名称
}

// ImageNameListView 只获取图片id 地址 名称
func (UploadsApi) ImageNameListView(c *gin.Context) {
	var list []ImagesNameList

	err := common.DB.Model(models.BannerModel{}).Debug().Select("id", "path", "name").Scan(&list).Error
	if err != nil {
		http.FailWithMessage("获取失败", c)
		return
	}
	http.IsOkWithData(list, c)
}
